{extend name="public/base" /}

{block name="content"}
<!--页面路径 和 页面标题-->
<div class="page-title">

    <div class="title-env">
        <h1 class="title">用户管理</h1>
        <p class="description">所有用户</p>
    </div>

    <div class="breadcrumb-env">

        <ol class="breadcrumb bc-1">
            <li>
                <a href="/admin"><i class="fa-home"></i>Home</a>
            </li>
            <li class="active">
                <strong>用户列表</strong>
            </li>
        </ol>

    </div>

</div>

<div class="row">
    <div class="col-md-12">

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">用户列表</font></font></h3>
                <div class="panel-options">
                    <div class="row">
                        <div class="col-sm-12">
                            <form role="form" class="form-inline" action="/admin/user/index">

                                <div class="form-group pull-left">
                                    <input type="text" name="title" class="form-control" size="25" placeholder="用户名" value="{$Think.get.title}">
                                </div>

                                <div class="form-group pull-left">
                                    <button class="btn btn-secondary btn-single">Search</button>
                                </div>

                                <div class="form-group pull-right">
                                    <a class="btn btn-icon btn-info" href="/admin/user/add" style="color: white">
                                        <i class="fa-plus"></i> 添加用户
                                    </a>
                                </div>

                            </form>
                        </div>
                    </div>

                </div>
            </div>

            <div class="panel-body panel-border">

                <div class="row">

                    <div class="col-sm-12">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>用户头像</th>
                                <th>用户名字</th>
                                <th>手机号</th>
                                <th>性别</th>
                                <th>生日</th>
                                <th>操作时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $lists as $key => $list}
                            <tr>
                                <td>{$key+1}</td>
                                <td>
                                    <img src="{$list.avatar}" width="50px" height="50px" style="border-radius: 50%">
                                </td>
                                <td>{$list.name}</td>
                                <td>{$list.mobile}</td>
                                <td>
                                    {if condition="$list.gender == 1"}
                                    <span class="badge badge-info"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">男</font></font></span>
                                    {/if}
                                    {if condition="$list.gender == 2"}
                                    <span class="badge badge-info"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">女</font></font></span>
                                    {/if}
                                    {if condition="$list.gender == 3"}
                                    <span class="badge badge-info"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">保密</font></font></span>
                                    {/if}
                                </td>
                                <td>{$list.birthday}</td>
                                <td>{$list.updated_at}</td>
                                <td>
                                    <a class="btn btn-icon btn-info" href="/admin/user/history/id/{$list.id}">
                                        <i class="fa-history"></i> 足迹
                                    </a>

                                    <a class="btn btn-icon btn-warning" href="/admin/user/collection/id/{$list.id}">
                                        <i class="fa-heart"></i> 收藏
                                    </a>

                                    <a class="btn btn-icon btn-success" href="/admin/user/edit/id/{$list.id}">
                                        <i class="fa-edit"></i>
                                    </a>

                                    <button class="btn btn-icon btn-red" onclick="deleted({$list.id},'user')">
                                        <i class="fa-trash"></i>
                                    </button>
                                </td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <label class="col-md-6 control-label">共 {$total} 条记录</label>
                    <div class="col-md-6 text-right">
                        <nav aria-label="Page navigation">
                            {$page}
                        </nav>
                    </div>
                </div>
            </div>

        </div>

    </div>
</div>
{/block}

{block name="js"}


<script>
    //删除用户
    function deleted(id,type) {
        if(confirm("是否确认删除")){
            $.ajax({
                url:'/admin/user/deleted',
                method: 'POST',
                dataType: 'json',
                data:{
                    id:id,
                    type:type
                },
                success: function(res)
                {
                    if(res.code == 0) {
                        success(res.message);
                        setTimeout("location.reload()",1000);
                    }else{
                        error(res.mssage);
                    }
                }
            })
        }
    };
</script>
{/block}